#!/usr/bin/env ruby
#
# Copyright 2009, Jeffrey Palm.
#

#
# This program just sends something that looks like a shared key to
# the local server to test if her handlerscan do their thing.
#

require 'socket'
require 'config'
require 'util'

# Returns a random string
def random_shared_key
  o =  [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten
  (0..50).map{ o[rand(o.length)]  }.join
end

# Sends a random shared key to mimic another device doing it.
def main(args)
  c = Config.get_instance args
  s = TCPSocket.open c.addr,c.port
  key = random_shared_key
  note 'Sending key: ' + key
  s.puts key
  s.close
end

main ARGV

